/*
 * Project Name demo
 * File Name MsgController
 * Package Name com.huxiaosu.demo.socketio
 * Create Time 2023/1/29
 * Create by name：liujie
 */
package com.huxiaosu.demo.socketio.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description
 *
 * @ClassName: MsgController
 * @author: liujie
 * @date: 2023/1/29 10:04
 */
@RestController
public class MsgController {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @GetMapping("send")
    public String send(){
        JSONObject msg = new JSONObject();
        msg.put("client",1);
        msg.put("msg","test");
        redisTemplate.convertAndSend("test",msg);
        return "0";
    }
}